e
#Title[uΉgHv]
#Text[NLOI
uΉgHv]
#BackGround[User]
#BGM[.\..\bgm\bgm.wav]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	
	////////////////////////////////////////////////////////////////////////
	//                                                          //
	//   way炵                                          //
	//   e̍ōx                                         //
	//   ڋߔ₳߂ɂ                                         //
	////////////////////////////////////////////////////////////////////////
	
	@Initialize{
		InitializeData();
		
		LoadUserShotData(shot_ryoyan);
		
		SetLife(1000);
		SetMovePosition03(GetCenterX(),180,10,8);
		SetDamageRate(28,16);
		SetInvincibility(240);
		SetCollisionEx(32,16);
		SetEnemyMarker(true);
		
		TMain();
	}
	
	@MainLoop{
		yield;
	}
	
	@DrawLoop{
		DrawBoss(imgBoss);
	}
	
	@Finalize{
		FinalizeData();
	}
	
	task TMain(){
		wait(60);
		
		DeclareSpell();
		
		Atack();
		Move();
	}
	
	function DeclareSpell(){
		SetTimer(90);
		CutIn(YOUMU,"uΉgHv",NULL,0,0,0,0);
		SetScore(1000000);
		wait(180);
	}
	
	task Atack(){
		danmaku02();
		let count=0;
		let color=[_RED05(),_ORANGE05()];
		while(true) {
			ascent(cnt in 0..12) {
				CreateShotA(0,GetX(),GetY(),0);
				SetShotDataA(0,0,1,GetAngleToPlayer()+cnt*360/12*p1m0(count),0,0.02,3,_ORANGE22());
				ascent(cnt in 1..70) {
					CreateShotA(1,rand(-5,5),rand(-5,5),rand_int(15,30));
					SetShotDataA(1,0,0,0,0,0,0,color[cnt%2]);
					SetShotKillTime(1,0);
					AddShot(cnt*2,0,1,0);
				}
				let id=FireShot(0);
				bomb( id,0,_RED01L() );
				wait(5);
			}
			count++;
			wait(70);
		}
	}
	
	task danmaku02() {
		let count = 0;
		let color = [_BLUE05(),_WHITE05()];
		loop{
			ascent(cnt in 3..6){
				ascent(cnt2 in 0..2){
					CreateShotA(0,GetX(),GetY(),0);
					SetShotDataA(0,0,1,90-(cnt)*25*p1m0(cnt2),0,0.02,4,_BLUE22());
					ascent(cnt in 1..70) {
						CreateShotA(1,rand(-5,5),rand(-5,5),rand_int(15,30));
						SetShotDataA(1,0,0,0,0,0,0,color[cnt%2]);
						SetShotKillTime(1,0);
						AddShot(cnt*2,0,1,0);
					}
					let id=FireShot(0);
					bomb( id,1,_BLUE01L() );
				}
			}
			
			count++;
			wait(140);
		}
	}
	
	function sekkinflag(let id) {
		let x = Obj_GetX(id);
		let y = Obj_GetY(id);
		let len = ( (GetPlayerY() - y) ^ 2 + (GetPlayerX() - x) ^ 2 ) ^ 0.5;
		return len > 50;
	}
	
	function dispinflag(let id) {
		let x = Obj_GetX(id);
		let y = Obj_GetY(id);
		let tm = (GetClipMinX() < x && GetClipMaxX() > x && GetClipMinY() < y && GetClipMaxY() > y);
		return tm;
	}
	
	task bomb(let id,let sw,let gp1) {
		if(sw == 0){
			while( !Obj_BeDeleted(id) && sekkinflag(id) ){
				yield;
			}
		}
		if(sw == 1){
			while( !Obj_BeDeleted(id) && dispinflag(id) ){
				yield;
			}
		}
		
		if( !Obj_BeDeleted(id) ){
			let ang = rand(0,360);
			let x = Obj_GetX(id);
			let y = Obj_GetY(id);
			loop(30){
				ang += 360 / 30;
				CreateShot02(x + cos(ang) * 10,y + sin(ang) * 10,1,ang,0.02,3.4,gp1,30);
			}
			Obj_Delete(id);
		}
	}
	
	task Move(){
		let tm = 0;
		
		loop{
			wait(60);
			tm = ( ( GetPlayerX() > GetX() ) - ( GetPlayerX() < GetX() ) ) * rand(10,30);
			SetMovePosition03(GetX() + tm,rand(150,170),10,5);
			wait(90);
		}
	}
	
	#include_function ".\..\functions\initialize.txt"
	#include_function ".\..\functions\color_set.txt"
	#include_function ".\..\functions\function.txt"
}
